// pages/index/index/index.js
const config = require("../../../utils/config.js")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    clothings:[],
    banners: [],
    imgUrl: ["../../../images/nav1.png", "../../../images/nav2.png", "../../../images/nav3.png"],
    pic: ["https://kiefaluo.gitee.io/beautifulgirl/images/pic1.png", "https://kiefaluo.gitee.io/beautifulgirl/images/pic2.png", "https://kiefaluo.gitee.io/beautifulgirl/images/pic3.png", "https://kiefaluo.gitee.io/beautifulgirl/images/pic4.png", "https://kiefaluo.gitee.io/beautifulgirl/images/pic5.png"],
    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 1000,
    id:"",
    categoryList:[],
    newGoodsList:[],
    hotGoodsList:[]
  },
  bindFocus: function (e) {
    console.log(e.currentTarget.dataset.index)
    
    wx.navigateTo({
      url: '../productList/productList?categoryList=' + JSON.stringify(this.data.categoryList[e.currentTarget.dataset.index])
    })
  },
  subscript:function(e){
    console.log(e)
    wx.navigateTo({
      url: '../productList/productList?categoryList=' + JSON.stringify(this.data.categoryList[e.currentTarget.dataset.index])
    })
  },
  yph:function(e){
    console.log(this.data.hotGoodsList)
    wx.navigateTo({
      url: '../productList/productList?categoryList=' + JSON.stringify(this.data.hotGoodsList)
    }
  )
  },
  yph2: function (e) {
    console.log(this.data.hotGoodsList)
    wx.navigateTo({
      url: '../productList/productList?categoryList=' + JSON.stringify(this.data.newGoodsList)
    }
    )
  },
  upgrade:function(){
    wx.navigateTo({
      url:"../../argent/argent"
    })
  },
  scrollT:function(){
    wx.createSelectorQuery().select('.anc').boundingClientRect(function (re) {
      wx.createSelectorQuery().select('.all').boundingClientRect(function (rect) {
      // 使页面滚动到底部
      wx.pageScrollTo({
        scrollTop: rect.height-re.height,
        duration: 2000
      })
      console.log(rect)
    }).exec()
    }).exec()

    
  },
  




  //  生命周期函数--监听页面加载
  onLoad: function (options) {
    
    wx.request({
      url:config.homePage,
      method:"GET",
     
      success: res => {
        
        this.setData({
          banners: res.data.data.banner,
          
          categoryList:res.data.data.categoryList,
          newGoodsList: res.data.data.newGoodsList,
          hotGoodsList: res.data.data.hotGoodsList
        });
        console.log(res)
      }
    })
    
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})